# Maintainer: Sebastian Ehlert <awvwgk@disroot.org>

_pyname=ConfigArgParse
_realname=configargparse
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.5.3
pkgrel=2
pkgdesc='A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables (mingw-w64)'
url='https://github.com/bw2/ConfigArgParse'
license=('MIT')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-yaml: for YAML support")
source=("https://github.com/bw2/ConfigArgParse/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha512sums=('bdc0340bd92cfd5319743a4860af80fc2352f38b156031856c2b39b8c8ad59461281009030c4451dd464334a829b8143c765979cfc9b8ccbe9fbdcb0e08ac7b4')

prepare() {
  cd ${srcdir}
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
      ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
